package com.sofoscorp.android.initdb;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

//DBHelper para BD ToSAP Logistica
public class DBHelperToSAP_LO extends SQLiteOpenHelper {

	//-------------- TABLA VBAK -------------------------------------	
			String sqlCreateVBAK = "CREATE TABLE IF NOT EXISTS VBAK (" + 
					                                   "DOCUMENT TEXT," +
						                               "AUART TEXT," +
						                               "VKORG TEXT," +
						                               "VTWEG TEXT," +
						                               "SPART TEXT," +
						                               "VKBUR TEXT," +
						                               "KUNNR TEXT," +
						                               "KUNNRW TEXT," +
						                               "BSARK TEXT," +
						                               "BSTZD TEXT," +
						                               "DZTERM TEXT," +
						                               "BSTDK TEXT," +
						                               "PRSDT TEXT," +
						                               "FKDAT TEXT," +
						                               "AUDAT TEXT," +
						                               "KETDAT TEXT," +
						                               "PERNR TEXT," +
						                               "TEXTO1 TEXT," +
						                               "TEXTO2 TEXT," +
						                               "KVGR1 TEXT," +
						                               "PRIMARY KEY (DOCUMENT)" +
								                       ")";			
			
	//-------------- TABLA VBAP -------------------------------------	
			String sqlCreateVBAP = "CREATE TABLE IF NOT EXISTS VBAP (" + 
					                                   "DOCUMENT TEXT," +
						                               "POSNR TEXT," +
						                               "MATNR TEXT," +
						                               "WERKS TEXT," +
						                               "MENGE REAL," +
						                               "MEINS TEXT," +
						                               "IHREZ TEXT," +
						                               "IHREZ_E TEXT," +
						                               "ROUTE TEXT," +
						                               "LGORT TEXT," +
						                               "CHARG TEXT," +
						                               "KBETR REAL," +
						                               "KMEIN TEXT," +
						                               "KPEIN INTEGER," +
						                               "KBETR1 REAL," +
						                               "KMEIN1 TEXT," +
						                               "KPEIN1 INTEGER," +
						                               "PRIMARY KEY (DOCUMENT, POSNR)" +
								                       ")";	
	
	public DBHelperToSAP_LO(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);

	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(sqlCreateVBAK); //Cabecera de Pedidos
		db.execSQL(sqlCreateVBAP); //Posicion de Pedidos
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(sqlCreateVBAK); //Cabecera de Pedidos
		db.execSQL(sqlCreateVBAP); //Posicion de Pedidos	
	}

}